Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes updates to controller's UnavailableSince field. #1246

Merged

Conversation

alesstimec
Copy link
Collaborator

@alesstimec alesstimec commented Jun 24, 2024

Description

We were never resetting controller's UnavailableSince field. So if JIMM was unable to dial the controller at some point, that controller would forever be shown as unavailable in jimmctl controllers output.

Engineering checklist

Check only items that apply

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

Notes for code reviewers

@alesstimec alesstimec requested a review from a team as a code owner June 24, 2024 08:11
internal/jimm/watcher.go Outdated Show resolved Hide resolved
@alesstimec alesstimec force-pushed the controller-unavailable-since-update branch from 4e4850d to f0144ad Compare June 24, 2024 08:39
Copy link

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

@alesstimec alesstimec force-pushed the controller-unavailable-since-update branch from f0144ad to fecbb65 Compare June 24, 2024 08:53
internal/jimm/watcher.go Outdated Show resolved Hide resolved
internal/jimm/watcher.go Outdated Show resolved Hide resolved
@alesstimec alesstimec force-pushed the controller-unavailable-since-update branch from fecbb65 to cc8debc Compare June 24, 2024 09:37
internal/jimm/watcher.go Outdated Show resolved Hide resolved
cerr := <-controllerUnavailableChannel
c.Assert(cerr, qt.IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to avoid the use of this channel in tests where we don't need to use them. Like here, we could just check the DB to verify that the UnavailableSince time is nil. It will also make it easier to refactor out the channel later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think tests need this channel for timing..

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe timing is handled by the cancel() call inside the AllModelWatcherNext_ mock + the waitGroup, so you should be able to safely remove this. And it would be good to check the DB and the UnavailableSince field since that is what the test is trying to assert.

wg.Add(1)
go func() {
defer wg.Done()
err := w.Watch(ctx, time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a side note, our watcher tests might want to consider adding a deadline of e.g. 5 seconds to the context, that way we avoid the test getting stuck and running for too long when writing new tests/modifying old ones.

cerr := <-controllerUnavailableChannel
c.Assert(cerr, qt.IsNil)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe timing is handled by the cancel() call inside the AllModelWatcherNext_ mock + the waitGroup, so you should be able to safely remove this. And it would be good to check the DB and the UnavailableSince field since that is what the test is trying to assert.

internal/jimm/watcher_test.go Outdated Show resolved Hide resolved
@alesstimec alesstimec force-pushed the controller-unavailable-since-update branch 2 times, most recently from e694741 to 869ec13 Compare June 24, 2024 10:29
@alesstimec alesstimec force-pushed the controller-unavailable-since-update branch from 869ec13 to 0b7b585 Compare June 24, 2024 10:36
@alesstimec alesstimec merged commit 10789ab into canonical:v3 Jul 4, 2024
4 checks passed
@alesstimec alesstimec deleted the controller-unavailable-since-update branch July 4, 2024 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants